package com.ysqcould.web.controller.activity;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ysqcould.activity.domain.vo.ReproduceVo;
import com.ysqcould.common.annotation.Log;
import com.ysqcould.common.core.controller.BaseController;
import com.ysqcould.common.core.domain.AjaxResult;
import com.ysqcould.common.core.page.TableDataInfo;
import com.ysqcould.common.enums.BusinessType;
import com.ysqcould.common.utils.poi.ExcelUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ysqcould.activity.domain.ActivityReproduce;
import com.ysqcould.activity.service.IActivityReproduceService;

/**
 * 活动转载记录Controller
 * 
 * @author ruoyi
 * @date 2022-08-12
 */
@RestController
@RequestMapping("/activity/reproduce")
public class ActivityReproduceController extends BaseController
{
    @Autowired
    private IActivityReproduceService activityReproduceService;

    /**
     * 查询活动转载记录列表
     */
    @PreAuthorize("@ss.hasPermi('activity:reproduce:list')")
    @GetMapping("/list")
    public TableDataInfo list(ActivityReproduce activityReproduce)
    {
        startPage();
        List<ReproduceVo> list = activityReproduceService.selectActivityReproduceList(activityReproduce);
        return getDataTable(list);
    }

    /**
     * 导出活动转载记录列表
     */
 /*   @PreAuthorize("@ss.hasPermi('activity:reproduce:export')")
    @Log(title = "活动转载记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ActivityReproduce activityReproduce)
    {
        List<ReproduceVo> list = activityReproduceService.selectActivityReproduceList(activityReproduce);
        ExcelUtil<ReproduceVo> util = new ExcelUtil<ActivityReproduce>(ActivityReproduce.class);
        util.exportExcel(response, list, "活动转载记录数据");
    }*/

    /**
     * 获取活动转载记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('activity:reproduce:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(activityReproduceService.selectActivityReproduceById(id));
    }

    /**
     * 新增活动转载记录
     */
    @PreAuthorize("@ss.hasPermi('activity:reproduce:add')")
    @Log(title = "活动转载记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ActivityReproduce activityReproduce)
    {
        activityReproduce.setAsId(getUserId());
        return toAjax(activityReproduceService.insertActivityReproduce(activityReproduce));
    }

    /**
     * 修改活动转载记录
     */
    @PreAuthorize("@ss.hasPermi('activity:reproduce:edit')")
    @Log(title = "活动转载记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ActivityReproduce activityReproduce)
    {
        return toAjax(activityReproduceService.updateActivityReproduce(activityReproduce));
    }

    /**
     * 删除活动转载记录
     */
    @PreAuthorize("@ss.hasPermi('activity:reproduce:remove')")
    @Log(title = "活动转载记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(activityReproduceService.deleteActivityReproduceByIds(ids));
    }
}
